﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WangMiEntity;
using WangMiBusiness.EmployeeService;
using WangMiEntity.GridViewModel;
using WangMiEntity.EmployeeService;
using WangMi.Constant;

namespace WangMi.Controllers
{
    public class GridDataController : Controller
    {
        /// <summary>
        /// 销售额
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult XiaoShoue(string id, string nick)
        {
            //switch (id)
            //{
            //    case "1":
            //        var result = new XiaoShoueBusiness().GetXiaoShoueByDate(DateTime.Now.AddDays(-60), DateTime.Now, WangMiConstant.SessionKey, false, "");
            //        GridModel<XiaoShoueDateEntity> test = new GridModel<XiaoShoueDateEntity>();
            //        test.aaData = result;
            //        return Json(test, JsonRequestBehavior.AllowGet);
            //    case "2":
            //        break;
            //    case "3":
            //        break;
            //}

            var result = new XiaoShoueBusiness().GetXiaoShoueByDate(DateTime.Now.AddDays(-60), DateTime.Now, WangMiConstant.SessionKey, false, "");
            GridModel<XiaoShoueDateEntity> test = new GridModel<XiaoShoueDateEntity>();
            test.aaData = result;
            return Json(test, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 销售量
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult XiaoShouLiang(string id)
        {
            var result = new XiaoShouLiangBusiness().GetXiaoShouLiangByDate(DateTime.Now.AddDays(-60), DateTime.Now, "6100a129c6e55ccc8dc91ec5d631f10c3b7fd0f432acdcc2052865997", true);

            GridModel<XiaoShouLiangDateEntity> test = new GridModel<XiaoShouLiangDateEntity>();
            test.aaData = result;

            return Json(test, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 客单价
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        //public JsonResult KeDanJia(string id)
        //{
        //    var result = new KeDanJiaBusiness().GetKeDanJiaByDate(DateTime.Now.AddDays(-60), DateTime.Now, "6100a129c6e55ccc8dc91ec5d631f10c3b7fd0f432acdcc2052865997", true);

        //    GridModel<KeDanJiaDateEntity> test = new GridModel<KeDanJiaDateEntity>();
        //    test.aaData = result;

        //    return Json(test, JsonRequestBehavior.AllowGet);
        //}

        /// <summary>
        /// 满意度
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult ManYiDu(string id)
        {
            var result = new ManYiDuBusiness().GetManYiDuByDate(DateTime.Now.AddDays(-60), DateTime.Now, "6100a129c6e55ccc8dc91ec5d631f10c3b7fd0f432acdcc2052865997", true);

            GridModel<ManYiDuDateEntity> test = new GridModel<ManYiDuDateEntity>();
            test.aaData = result;

            return Json(test, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 客件数
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult KeJianShu(string id)
        {
            var result = new KeJianShuBusiness().GetKeJianShuByDate(DateTime.Now.AddDays(-60), DateTime.Now, "6100a129c6e55ccc8dc91ec5d631f10c3b7fd0f432acdcc2052865997", true);

            GridModel<KeJianShuDateEntity> test = new GridModel<KeJianShuDateEntity>();
            test.aaData = result;

            return Json(test, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 转化率
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult ZhuanHuaLv(string id)
        {
            var result = new ZhuanHuaLvBusiness().GetZhuanHuaLvByDate(DateTime.Now.AddDays(-8), DateTime.Now.AddDays(-1), "6100a129c6e55ccc8dc91ec5d631f10c3b7fd0f432acdcc2052865997", true, "fdas");

            GridModel<ZhuanHuaLvDateEntity> test = new GridModel<ZhuanHuaLvDateEntity>();
            test.aaData = result;

            return Json(test, JsonRequestBehavior.AllowGet);
        }
    }
}
